<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$_SESSION['forward_url']='jy_ylfee/index/';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$member=$this->get('member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['setting']=$this->plugin_setting('page_setting');
	$params=array('mid'=>$_SESSION['uid']);
	if($_RQ['type']){
		$params['level']=$_RQ['type'];
	}
	$return['commission_money']=$this->sum('commission',$params,'money');
	$return['commission_total']=$this->count('commission',$params);
	$levels=array();
	$return['area_types']=$this->area_types;
	$return['levels']=array(
		'1'=>'区域绩效',
		'2'=>'招商奖',
		'3'=>'培育奖',
	);
	$return['list']=array();
	$return['params']=array(
		'level'=>$_RQ['type']?:2,
		'page'=>1,
	);
	$return['psize']=20;
	$return['xuniname']=$this->xuniname;
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']);
	if(intval($_RQ['isarea'])){
		$level=16;
	}elseif(intval($_RQ['isxuni'])){
		$level=18;
	}else{
		$level=intval($_RQ['level']);
		if(!$level){
			$level=2;
		}
	}
	$params['level']=$level;
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		
	);
	$list=$this->get_list('commission',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		$order=$this->get('order',array('ordersn'=>$item['ordersn'],'uniacid'=>$_SESSION['uniacid']));
		$item['member']=model('core/member')->basic($order['mid']);
		if($level>=4){
			$item['ordersn']='流水基数: ￥'.$item['jifee'];
		}
		$item['status']=$this->commission_status[$item['status']];
	}
	//exi('num'.count($list),'error');
	exi($list);
}
?>